<div class="row" style="border-bottom: 10px solid #EFEFEF;padding:10px;">
	<div class="col-lg-8">
		<div class="ukefu-measure">
			<div class="ukefu-bt">
				<div	class="layui-icon ukewo-btn ukefu-content-ind"><img src="/images/weixin.jpg" style="width:60px;height:60px;"></div>
				<div class="ukefu-bt-text">
					<div class="ukefu-bt-text-title"
						 style="font-weight:400;font-size:24px;border-bottom:1px solid #dedede;">
						${snsAccount.name!''}
						<span style="font-size:15px;color:#AAAAAA;">公众号创建时间：${snsAccount.createtime!?string("yyyy-MM-dd HH:mm:ss")}</span>
					</div>
					<div class="ukefu-bt-text-content" style="">${snsAccount.name!''}</div>
				</div>
			</div>
		</div>
	</div>
	<div class="col-lg-4">
		<form class="layui-form" action="/admin/weixin/update.html"	method="post">
			<div class="layui-form-item">
				<label class="layui-form-label">
					人工坐席：
				</label>
				<div class="layui-input-block ukefu-agent-switch" style="padding-top:0px;">
					<input type="checkbox" name="switch" <#if snsAccount.agent?? && snsAccount.agent == true>checked</#if> lay-filter="agent" lay-skin="switch" value="1" lay-text="开启|关闭">
			</div>
	</div>
	</form>
</div>
</div>
<div class="row" style="border-bottom: 10px solid #EFEFEF;padding:10px;">
	<div class="col-lg-12">
		<span style="font-weight:600;">接口地址：</span>${schema!''}://${hostname!''}<#if port?? && port != '80'>:${port?string('###')}</#if>/im/weixin/${snsAccount.snsid!''}
	<span style="font-weight:600;margin-left:50px;">Token：</span>${snsAccount.token!''}
	<span style="font-weight:600;margin-left:50px;">AppID：</span>${snsAccount.appkey!''}
</div>
</div>
<div class="ukefu-tab-title" style="margin-left: 0px;">
	<#include "/admin/channel/weixin/include/top.html">
</div>

<div class="row">
	<div class="col-lg-12" >
		<div class="">
			<form class="layui-form" action="/admin/weixin/menu/update.html" method="post">
				<input type="hidden" name="id" value="${menu.id!''}">
				<div class="layui-collapse">
					<div class="layui-colla-item">
						<h2 class="layui-colla-title">菜单基本信息</h2>
						<div class="layui-colla-content layui-show">
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">菜单名称：</label>
									<div class="layui-input-inline">
										<input type="text" name="name" value="${menu.name!''}" autocomplete="off"	class="layui-input" lay-verify="required">
									</div>
								</div>
								<div class="layui-inline">
									<font color="red">* 一级菜单最多4个汉字，二级菜单最多7个汉字</font>
								</div>
							</div>

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">上级菜单：</label>
									<div class="layui-input-inline">
										<select  name="parentid" >
											<option value="">请选择上级菜单</option>
											<#if parentList?? && parentList?size gt 0>
											<#list parentList as menuParent>
											<option value="${menuParent.id}" <#if menuParent.id == menu.parentid>selected=selected</#if> >${menuParent.name!''}</option>
											</#list>
										</#if>
										</select>
									</div>
								</div>
								<div class="layui-inline">
									<font color="red">最多支持二级菜单，不填为一级菜单</font>
								</div>
							</div>

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">菜单序号：</label>
									<div class="layui-input-inline">
										<input type="number" name="sortindex" autocomplete="off" value="${menu.sortindex!0}" lay-verify="required"	class="layui-input">
									</div>
								</div>
							</div>

						</div>
					</div>


					<div class="layui-colla-item">
						<h2 class="layui-colla-title">菜单内容（一级菜单以下可以不填写）</h2>
						<div class="layui-colla-content layui-show">
							<div class="layui-form-item" >
								<div class="layui-inline">
									<label class="layui-form-label">菜单类型：</label>
									<div class="layui-input-inline">
										<select  name="type" lay-filter="btn_type" >
											<option value="">请选择菜单类型</option>
											<#if menuButtonType??>
													<#list menuButtonType?keys as key>
													<option value="${key}" <#if key == menu.type>selected=selected</#if> >${menuButtonType[key]}</option>
												</#list>
											</#if>
										</select>
									</div>
								</div>
							</div>
							<div class="layui-form-item type-item click-item" >
								<div class="layui-inline">
									<label class="layui-form-label">自定义key：</label>
									<div class="layui-input-inline">
										<input type="text" name="keyv" autocomplete="off" value="${menu.keyv}"	class="layui-input">
									</div>
								</div>
							</div>

							<div class="layui-form-item type-item view-item miniprogram-item" >
								<div class="layui-inline">
									<label class="layui-form-label">跳转url：</label>
									<div class="layui-input-inline">
										<input type="text" name="url" autocomplete="off"	value="${menu.url}"class="layui-input">
									</div>
								</div>
							</div>


							<div class="layui-form-item type-item miniprogram-item" >
								<div class="layui-inline">
									<label class="layui-form-label">小程序appid：</label>
									<div class="layui-input-inline">
										<input type="text" name="appid" autocomplete="off"	class="layui-input" value="${menu.appid}">
									</div>
								</div>
							</div>
							<div class="layui-form-item type-item miniprogram-item" >
								<div class="layui-inline">
									<label class="layui-form-label">小程序备用url：</label>
									<div class="layui-input-inline">
										<input type="text" name="pagepath" autocomplete="off"	class="layui-input" value="${menu.pagepath}">
									</div>
								</div>
							</div>

							<div class="layui-form-item type-item media-item" >
								<div class="layui-inline">
									<label class="layui-form-label">素材id：</label>
									<div class="layui-input-inline">
										<input type="text" name="mediaid" autocomplete="off" id="mediaid" value="${menu.mediaid}"	class="layui-input">
									</div>
									<div class="layui-inline">
										从素材库选择
									</div>
									<div class="layui-inline" >
										<button type="button" class="layui-btn  layui-btn-sm media-item-btn media-news" id="selectImage">选择图片</button>
									</div>
									<div class="layui-inline">
										<button type="button" class="layui-btn  layui-btn-sm media-item-btn media-news" id="selectVideo">选择视频</button>
									</div>
									<div class="layui-inline">
										<button type="button" class="layui-btn  layui-btn-sm media-item-btn media-news" id="selectVoice">选择音频</button>
									</div>
									<div class="layui-inline">
										<button type="button" class="layui-btn  layui-btn-sm media-item-btn " id="selectNews">选择图文</button>
									</div>
								</div>
							</div>


						</div>
					</div>
			</div>

			<div class="layui-form-button" style="position:relative !important;">
				<div class="layui-button-block">
					<button class="layui-btn" lay-submit>保存</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		</div>
	</div>
</div>

<script>
    layui.use(['form','layer'], function(){
        var form = layui.form;
        var layer = layui.layer;
        form.render();
        $(".type-item").hide();

        var thistype = '${menu.type}';
        if(thistype == 'media_id' || thistype == 'view_limited'  ){
            $('.media-item').show();
            $('.media-item-btn').show();
            if(thistype == 'view_limited'){
                $('.media-news').hide();
            }
        }else if(thistype== 'miniprogram'){
            $('.miniprogram-item').show();
        }else if(thistype == 'view'){
            $('.view-item').show();
        }else{
            $('.click-item').show();
        }

        form.on('select(btn_type)' , function(data){
            $(".type-item").hide();
            if(data.value == 'media_id' || data.value == 'view_limited'  ){
                $('.media-item').show();
                $('.media-item-btn').show();
                if(data.value == 'view_limited'){
                    $('.media-news').hide();
				}
            }else if(data.value == 'miniprogram'){
                $('.miniprogram-item').show();
            }else if(data.value == 'view'){
                $('.view-item').show();
            }else{
                $('.click-item').show();
			}
        })

		var showMedia = function(type){
            top.iframe = window.frameElement && window.frameElement.id || '';
            top.layerwin = top.layer
                .open({
                    title : "选择素材",
                    type : 1,
                    id : 'mainajaxwin',
                    area : [
                        800 + "px",
                        600 + "px" ],
                    maxmin : true,
                    anim : 2,
                    move : false,
                    content : loaddingtip,
                    success:function(layero, index){
                        $.ajax({
                            url:'/admin/weixin/menu/getMedia.html?id=${snsAccount.id!""}&type=' + type,
                            cache:false,
                            success: function(data){
                                top.$('#mainajaxwin').empty().append(data);
                            }
                        });
                    },btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        $("#mediaid").val($(layero).find("#mediaid123").val());
                        layer.closeAll();
                        top.layer.closeAll();
                    },
                });
            return false;
		}
        $("#selectImage").click(function () {
            showMedia("image");
            return false;
        });
        $("#selectVideo").click(function () {
            showMedia("video");
            return false;
        });

        $("#selectVoice").click(function () {
            showMedia("voice");
            return false;
        });
        $("#selectNews").click(function () {
            showMedia("news");
            return false;
        });
    });
</script>


